﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="CheckInfoForm.cs" company="HelloWorld">
//   BY黄媛媛
// </copyright>
// <summary>
//   Defines the CheckInfoForm type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace WindowsFormsApp2.Form
{
    using System;
    using System.Windows.Forms;

    using WindowsFormsApp2.Service;

    /// <summary>
    /// The check info form.
    /// </summary>
    public partial class CheckInfoForm : Form
    {
        /// <summary>
        /// The deadline manage.
        /// </summary>
        private readonly DDLManage ddlManage;

        /// <summary>
        /// The course id.
        /// </summary>
        private readonly string courseId;

        /// <summary>
        /// Initializes a new instance of the <see cref="CheckInfoForm"/> class.
        /// </summary>
        /// <param name="courseId">
        /// The course id.
        /// </param>
        /// <param name="courseName">
        /// The course name.
        /// </param>
        public CheckInfoForm(string courseId, string courseName)
        {
            this.courseId = courseId;
            this.InitializeComponent();
            this.label1.Text += courseId;
            this.label2.Text += courseName;
            this.ddlManage = new DDLManage(courseId);
            this.dataGridView1.DataSource = this.ddlManage.DDLDataTable;
        }

        /// <summary>
        /// The button 2_ click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void Close_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        /// <summary>
        /// The delete deadline button_ click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void DeleteDDLBtn_Click(object sender, EventArgs e)
        {
            var ddlName =
                (string)this.ddlManage.DDLDataTable.Rows[this.dataGridView1.CurrentCell.RowIndex][0]; // 从ddl数据表中取出ddl名称
            this.ddlManage.DeleteDDL(this.courseId, ddlName);
        }
    }
}
